# init script for interactive shells

# 下面是输出当前文件的相对路径
# cd $(dirname $BASH_SOURCE)
# temp_file=`echo $(pwd)/$(basename $BASH_SOURCE)`
# echo $temp_file

# BASH_SOURCE[0] 等价于 BASH_SOURCE ，取得当前执行的 shell 文件所在的路径及文件名
# "$(cd "${ dirname BASH_SOURCE[0]}" && pwd)"

# prevent loading twice
if [ -z "$_INIT_SH_LOADED" ]; then
	_INIT_SH_LOADED=1
else
	return
fi

# skip if in non-interactive mode
case "$-" in
	*i*) ;;
	*) return
esac

# execute local init script if it exists
if [ -f "$HOME/.local/etc/config.sh" ]; then
	source "$HOME/.local/etc/config.sh"
fi

# execute python virtualenvwrapper if it exists
if [ -f "/usr/bin/virtualenvwrapper_lazy.sh" ]; then
    source /usr/bin/virtualenvwrapper_lazy.sh
fi

# run script for interactive mode of bash/zsh
if [[ $- == *i* ]] && [ -z "$INIT_SH_NOFUN" ]; then
    if [ -f "$HOME/.local/etc/function.sh" ]; then
        source "$HOME/.local/etc/function.sh"
    fi
fi

# check if login shell
if shopt -q login_shell; then
    if [ -f "$HOME/.local/etc/login.sh" ] && [ -z "$INIT_SH_NOLOG" ]; then
        source "$HOME/.local/etc/login.sh"
    fi

    if [ -f "$HOME/.local/etc/colors.sh" ]; then
        source "$HOME/.local/etc/colors.sh"
    fi
fi

# execute post script if it exists
if [ -f "$HOME/.local/etc/local.sh" ]; then
	source "$HOME/.local/etc/local.sh"
fi

rm_dup_path
